package com.itheima.web;

import com.itheima.dto.OrdersDto;
import com.itheima.mapper.OrderDetailDao;
import com.itheima.mapper.OrdersDao;
import com.itheima.pojo.Orders;
import com.itheima.result.R;
import com.itheima.service.OrdersDtoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;

/**
 * @Author: 斌
 * @DateTime: 2023年02月12日  21:02:39
 * @Description: com.itheima.web
 * @Version: 1.0
 */
@RestController
@Slf4j
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrdersDtoService ordersDtoService;
    @PostMapping("/submit")
    public R submitOrder(@RequestBody Orders orders){

       return ordersDtoService.submitOrder(orders);
    }
    @GetMapping("/userPage")
    public R pageOrder(Integer page,Integer pageSize){

        return ordersDtoService.pageOrder(page,pageSize);
    }
    @GetMapping("/page")
    public R ordersPage(Integer page, Integer pageSize, Long number, String beginTime,String endTime){
       return ordersDtoService.ordersPage(page,pageSize,number,beginTime,endTime);
    }

    @PutMapping
    public R updateStatus(@RequestBody Orders orders){
        return ordersDtoService.updateStatus(orders);
    }
    @PostMapping("/again")
    public R againOrders(@RequestBody Orders orders){
        return ordersDtoService.againOrders(orders);
    }
    @GetMapping("/export")
    public void exportOrders(HttpServletResponse response){
        ordersDtoService.exportOrders(response);
    }

}
